﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter2.Section4
{
    public class Example04
    {
        public Example04()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double, double[]> map
                = new V.Function.ToLastType<double, double[]>(func);
            V.Path p = new V.Path(map);
            p.ParameterFrom = 0.0;
            p.ParameterTo = 20.0;
            V.Curve c = new V.Curve(p);
            c.Find(0.1);
            for (int i = 0; i < c.CoordinatesOfPoints.Count; i++)
            {
                double[] y = (double[])c.CoordinatesOfPoints[i];
                result += y[0].ToString() + "\t  ";
                result += y[1].ToString() + "\r\n";
            }
        }
        private double[] func(double t)
        {
            double[] r = new double[2];
            r[0] = t - Math.Sin(t);
            r[1] = 1.0 - Math.Cos(t);
            return r;
        }
    }
}
/*
0	  0
0.000166583353171851	  0.00499583472197418
0.00133066920493879	  0.0199334221587584
0.00447979333866044	  0.044663510874394
0.0105816576913495	  0.0789390059971149
0.020574461395797	  0.122417438109627
0.0353575266049646	  0.174664385090322
0.0557823127623089	  0.235157812715512
0.0826439091004773	  0.303293290652835
0.116673090372517	  0.378390031729336
0.158529015192103	  0.45969769413186
0.208792639938565	  0.546403878574423
0.267960914032774	  0.637642245523327
0.336441814582807	  0.732501171375413
0.41455027001154	  0.830032857099759
0.502505013395946	  0.929262798332297
0.600426396958495	  1.02919952230129
0.708335189547532	  1.12884449429552
0.826152369121805	  1.22720209469309
0.953699912312586	  1.3232895668635
1.09070257317432	  1.41614683654714
1.23679063335113	  1.50484610459986
1.39150359618041	  1.58850111725535
1.55429478782328	  1.66627602127982
1.72453681944885	  1.73739371554125
1.90152785589604	  1.80114361554693
2.08449862817854	  1.85688875336895
2.27262011976617	  1.90407214201706
2.4650118498441	  1.94222234066866
2.66075067078602	  1.97095816514959
2.85887999194013	  1.98999249660045
3.05841933756671	  1.99913515027328
3.25837414342758	  1.99829477579475
3.45774569414325	  1.98747976990886
3.65554110202683	  1.96679819257946
3.85078322768962	  1.9364566872908
4.04252044329485	  1.89675841633415
4.22983614090849	  1.84810003171041
4.41185789094272	  1.79096771191442
4.58776615918397	  1.72593230420014
4.75680249530793	  1.65364362086361
4.91827711106441	  1.57482394653327
5.07157577241359	  1.4902608213407
5.21616593674946	  1.40079917207998
5.35160207388952	  1.30733286997842
5.4775301176651	  1.21079579943078
5.59369100363346	  1.11215252693505
5.6999232575641	  1.01238866346289
5.79616460883584	  0.912501016560553
5.88245261262433	  0.813487630577424
5.95892427466314	  0.716337814536774
6.02581468232773	  0.622022257287019
6.08345465572015	  0.531483328699623
6.1322674422239	  0.445625663820838
6.17276448755599	  0.365307124057365
6.20554032557039	  0.29133022570874
6.23126663787232	  0.22443412148975
6.25068554259764	  0.16528721516084
6.26460217941376	  0.114480483058681
6.27387666483024	  0.0725215692559641
6.27941549819893	  0.039829713349634
6.2821625042721	  0.0167315615574153
6.2830894028175	  0.0034579029767825
6.28318609951565	  0.0001413636165849
6.28345079514951	  0.00681508124180741
6.28488001191218	  0.0234123742719765
6.28845863648662	  0.0497674080414707
6.2951500793834	  0.0856168517646806
6.30588664886139	  0.130602509650175
6.3215602356118	  0.184274899874643
6.34301340128121	  0.246097745656695
6.37103095987412	  0.315453333557194
6.40633213615085	  0.391648685467745
6.44956337937144	  0.473922482618895
6.50129190418837	  0.56145267242561
6.56200002322526	  0.653364682164974
6.63208032796851	  0.748740157417745
6.711831766123	  0.846626137962136
6.8014566546254	  0.946044579437351
6.90105865816023	  1.04600212563954
7.01064175337662	  1.14550003380861
7.13011018915491	  1.24354415373579
7.25926944332023	  1.33915486098384
7.39782816624371	  1.43137684497062
7.54540109191172	  1.51928865411669
7.70151288737651	  1.60201190268482
7.86560290212589	  1.67872004732001
8.03703076991782	  1.7486466455974
8.21508280710824	  1.81109301406166
8.39897914354212	  1.86543520924111
8.58788151475824	  1.91113026188468
8.78090163765065	  1.94772160213111
8.97711008589975	  1.97484362140416
9.17554557649294	  1.9922253254526
9.37522457454664	  1.99969304203521
9.57515112046181	  1.99717215619638
9.77432678122298	  1.98468785579413
9.97176062641095	  1.96236487983131
10.1664791292519	  1.93042627210475
10.3575358937753	  1.88919115262536
10.5440211108894	  1.83907152907645
10.7250706488929	  1.78056818016918
10.8998746875935	  1.7142656520272
11.0676858097636	  1.64082641759499
11.2278264690857	  1.56098425742723
11.3796957599717	  1.47553692799599
11.5227754216128	  1.38533819077183
11.6566350162702	  1.29128928172134
11.7809362300665	  1.19432990645533
11.8954362533064	  1.09542885100095
11.9999902065507	  0.995574302011949
12.094552588204	  0.895763973134301
12.1791777291513	  0.796995136181248
12.2540192499021	  0.700254656722985
12.3193285256647	  0.606509133652109
12.3754521746884	  0.516695241246994
12.4228285949687	  0.431710370232025
12.461983583919	  0.352403661346123
12.4935250847771	  0.279567521009161
12.518137112237	  0.213929703858961
12.5365729180004	  0.156146041267508
12.5496474645346	  0.106793888490677
12.5582292822368	  0.0663663559253621
12.5632317913658	  0.0352673821133902
12.5656041754483	  0.0138076977211363
12.5663218973512	  0.00220172082141934
12.5663769527789	  0.000565414498995276
12.5667679585801	  0.00891512818574702
12.5684901748985	  0.0271674343025646
12.5725255608623	  0.0551399618401394
12.5798329631734	  0.0925532185498038
12.5913385356276	  0.139033383537694
12.6079264852928	  0.19411604235955
12.6304302378034	  0.257250827296331
12.6596241100476	  0.327806916446532
12.6962155734484	  0.405079336690108
12.7408381851435	  0.488296007546853
12.7940452576915	  0.576625455549336
12.8563043305559	  0.669185122050953
12.927992498605	  0.765050181460177
13.0093926443051	  0.863262781792166
13.1006906112521	  0.962841615209175
13.2019733472836	  1.06279172292408
13.3132280357254	  1.16211443649972
13.4343422234507	  1.25981735621376
13.5651049444753	  1.3549242667887
13.7052088278595	  1.44648489141227
13.8542531688571	  1.53358438658912
14.0117479326247	  1.61535248295472
14.177118650488	  1.69097218071913
14.3497121598429	  1.75968791285882
14.52880313034	  1.82081309449267
14.7136013111462	  1.87373698301108
14.9032594268694	  1.91793078041429
15.0968816432543	  1.95295291688718
15.2935325180622	  1.97845346281888
15.4922463477006	  1.99417762518382
15.6920368162141	  1.99996829334934
15.8919068502277	  1.99576760887329
16.0908585813742	  1.98161754360638
16.2879033166651	  1.95765948032338
16.482071417184	  1.92413280007313
16.6724219863985	  1.88137249036223
16.8580522712868	  1.82980579807065
17.038106682348	  1.76994796054207
17.2117853423691	  1.70239705750271
17.3783520785343	  1.62782803524639
17.5371417780197	  1.54698596279424
17.6875670335815	  1.46067858741136
17.8291240127344	  1.36976826386317
17.9613974918796	  1.2751633380516
18.0840650050816	  1.17780907112312
18.1969000660416	  1.07867819473184
18.299774431073	  0.978761191826354
18.3926593804706	  0.879056400071522
18.4756260054682	  0.780560036788541
18.5488444979181	  0.684256245080757
18.6125824497912	  0.59110726060112
18.6672021794856	  0.502043797211585
18.7131571116615	  0.417955747597875
18.7509872467717	  0.33968329175592
18.7813137655555	  0.268008502191053
18.8048328224063	  0.203647529708077
18.8223085896267	  0.147243447869127
18.8345656220719	  0.09935982761523
18.8424806184696	  0.060475106251744
18.8469736617366	  0.0309778070609501
18.8489990258142	  0.0111626573058541
18.8495356408784	  0.0012276434127898
18.8495773121932	  0.00127203275649856
18.850122790337	  0.0112953818133308
18.852165792017	  0.0311975405927899
18.8566850711801	  0.0607796533031304
18.8646346396271	  0.0997461452526955
18.8769342348423	  0.147707676134538
18.8944601302804	  0.204185030186056
18.9180363799319	  0.268613904354503
18.9484265846479	  0.340350546626541
18.9863262624929	  0.418678188185564
19.0323558993583	  0.502814205128798
*/
